package com.wj.symbol;

/**
 * @author wen.jie
 * @date 2021/8/23 9:55
 */
public class SortedSymbolTable<K extends Comparable<K>, V> extends SymbolTable<K, V>{

    public void put(K k,V v){
        Node curr = head.next;
        Node pre = head;

        //找到新节点需要插入的位置
        while (curr != null && k.compareTo(curr.k) > 0){
            pre = curr;
            curr = curr.next;
        }

        if(curr != null && k.compareTo(curr.k) == 0){
            curr.v = v;
            return;
        }
        pre.next = new Node(k, v, curr);
        N++;
    }
}
